#include<stdio.h>
 int main()
{int a,b,c;
   scanf("%d %d",&a,&b);
   while(a%b!=0)
   {
     c=b;
     b=a%b;
     a=c;
    }
   printf("%d\n",b); 
}
